/*
** xfct_s.c for  in /home/jousse_f//workspace/SysUnix/ftp
** 
** Made by florian jousseau
** Login   <jousse_f@epitech.net>
** 
** Started on  Wed Apr  4 11:19:48 2012 florian jousseau
** Last update Wed Apr  4 11:38:42 2012 florian jousseau
*/

#include "server.h"

int	xsocket(int domain, int type, int protocol)
{
  int	ret;

  ret = socket(domain, type, protocol);
  if (ret == -1)
    {
      printf("Error on socket\n");
      exit(EXIT_FAILURE);
    }
  return (ret);
}

int	xbind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
  int	ret;

  ret = bind(sockfd, addr, addrlen);
  if (ret == -1)
    {
      printf("Error on bind\n");
      close(sockfd);
      exit(EXIT_FAILURE);
    }
  return (ret);
}

int	xlisten(int sockfd, int backlog)
{
  int	ret;

  ret = listen(sockfd, backlog);
  if (ret == -1)
    {
      printf("Error on listen\n");
      close(sockfd);
      exit(EXIT_FAILURE);
    }
  return (ret);
}

int	xaccept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
  int	ret;

  ret = accept(sockfd, addr, addrlen);
  if (ret == -1)
    {
      printf("Error on accpet\n");
      close(sockfd);
      exit(EXIT_FAILURE);
    }
  return (ret);
}
